<?php

namespace common\models\Art;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use frontend\models\ArtForm;

/**
 * ArtSearch represents the model behind the search form about `common\models\Art\Art`.
 */
class ArtSearch extends ArtForm
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'status', 'created_at', 'updated_at'], 'integer'],
            [['title', 'subhead', 'intro', 'img', 'author', 'reason', 'link', 'content', 'seocontent', 'seokeyword', 'display', 'member_id'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = ArtForm::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'display' => $this->display,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'subhead', $this->subhead])
            ->andFilterWhere(['like', 'intro', $this->intro])
            ->andFilterWhere(['like', 'img', $this->img])
            ->andFilterWhere(['like', 'author', $this->author])
            ->andFilterWhere(['like', 'reason', $this->reason])
            ->andFilterWhere(['like', 'link', $this->link])
            ->andFilterWhere(['like', 'content', $this->content])
            ->andFilterWhere(['like', 'seocontent', $this->seocontent])
            ->andFilterWhere(['like', 'seokeyword', $this->seokeyword])
            ->andFilterWhere(['like', 'display', $this->display])
            ->andFilterWhere(['like', 'member_id', $this->member_id]);

        return $dataProvider;
    }
	 public function checksearch($params)
    {
        $query = ArtForm::find()->andWhere(['display'=>ArtForm::DIS_SUCCESS])->orderBy('id desc');

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'display' => $this->display,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

       $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'subhead', $this->subhead])
            ->andFilterWhere(['like', 'intro', $this->intro])
            ->andFilterWhere(['like', 'img', $this->img])
            ->andFilterWhere(['like', 'author', $this->author])
            ->andFilterWhere(['like', 'reason', $this->reason])
            ->andFilterWhere(['like', 'link', $this->link])
            ->andFilterWhere(['like', 'content', $this->content])
            ->andFilterWhere(['like', 'seocontent', $this->seocontent])
            ->andFilterWhere(['like', 'seokeyword', $this->seokeyword])
           ->andFilterWhere(['like', 'display', $this->display])
            ->andFilterWhere(['like', 'member_id', $this->member_id]);

        return $dataProvider;
    }
        /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function unchecksearch($params)
    {
        $query = ArtForm::find()->andWhere(['display'=>ArtForm::DIS_DELETED])->orderBy('id desc');
        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'display' => $this->display,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

      $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'subhead', $this->subhead])
            ->andFilterWhere(['like', 'intro', $this->intro])
            ->andFilterWhere(['like', 'img', $this->img])
            ->andFilterWhere(['like', 'author', $this->author])
            ->andFilterWhere(['like', 'reason', $this->reason])
            ->andFilterWhere(['like', 'link', $this->link])
            ->andFilterWhere(['like', 'content', $this->content])
            ->andFilterWhere(['like', 'seocontent', $this->seocontent])
            ->andFilterWhere(['like', 'seokeyword', $this->seokeyword])
            ->andFilterWhere(['like', 'display', $this->display])
            ->andFilterWhere(['like', 'member_id', $this->member_id]);


        return $dataProvider;
    }
            /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function waitchecksearch($params)
    {
        $query = ArtForm::find()->andWhere(['display'=>ArtForm::DIS_ACTIVE])->orderBy('id desc');
        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
			 'display' => $this->display,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'subhead', $this->subhead])
            ->andFilterWhere(['like', 'intro', $this->intro])
            ->andFilterWhere(['like', 'img', $this->img])
            ->andFilterWhere(['like', 'author', $this->author])
            ->andFilterWhere(['like', 'reason', $this->reason])
            ->andFilterWhere(['like', 'link', $this->link])
            ->andFilterWhere(['like', 'content', $this->content])
            ->andFilterWhere(['like', 'seocontent', $this->seocontent])
            ->andFilterWhere(['like', 'seokeyword', $this->seokeyword])
            ->andFilterWhere(['like', 'display', $this->display])
            ->andFilterWhere(['like', 'member_id', $this->member_id]);


        return $dataProvider;
    }
}
